package com.qf.day06;

/**
 * 🐟的父类是Animal
 * extends 父类的类名
 */
public class Fish extends Animal implements Comparable<Fish>{

    private String color;

    // 🐟是否有鳞片
    private boolean linpian;

    // 🐟是否还活着
    private boolean alive = true;

    // 构造方法
    public Fish() {
        super();
    }

    public Fish(String name, String type, String sex, int age, String color, boolean linpian) {
        super(name, type, sex, age);
        this.color = color;
        this.linpian = linpian;
    }

    public void swim(){
        System.out.println(getName()+"在游泳");
        int hungry = getHungry();
        setHungry(hungry+1);
    }

    public void yaoGou(){
        System.out.println(getName()+" 咬勾了");
        this.alive = false;
    }


    @Override
    public void eat() {
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("鱼吃饭前喝点");
        int hungry = getHungry();
        setHungry(hungry-2);
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~");
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public boolean isLinpian() {
        return linpian;
    }

    public void setLinpian(boolean linpian) {
        this.linpian = linpian;
    }

    public boolean isAlive() {
        return alive;
    }

    public void setAlive(boolean alive) {
        this.alive = alive;
    }

    @Override
    public String toString() {
        return "Fish{" +
                "name='" + getName() + '\'' +
                ", type='" + getType() + '\'' +
                ", sex='" + getSex() + '\'' +
                ", age=" + getAge() +
                ", hungry=" + getHungry() +
                ", color='" + color + '\'' +
                ", linpian=" + linpian +
                ", alive=" + alive +
                "} ";
    }

    public int compareTo(Fish o){
        int age = this.getAge();
        // 获取比较对象的年龄
        int targetAge = o.getAge();

        return age-targetAge;
    }
}
